﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BLL
{
    public class IntegralBase
    {
        #region 产品信息添加
        /// <summary>
        /// 产品信息添加
        /// </summary>
        /// <param name="integral"></param>
        /// <returns></returns>
        public static string CreateIntegral(Model.IntegralHistoryBase integral)
        {
            string result = (new SQLServerDAL.IntegralBase()).CreateIntegral(integral);

            if (result.IndexOf("succeeded") >= 0)
            {
                string regradingObjectId = result.Split('|')[1];

                if (result == "succeeded")
                    result += "|" + regradingObjectId;
            }

            return result;
        }
        #endregion

        #region 产品信息修改
        /// <summary>
        /// 产品信息修改
        /// </summary>
        /// <param name="integral"></param>
        /// <returns></returns>
        public static string ModifyIntegral(Model.IntegralHistoryBase integral)
        {
            string result = (new SQLServerDAL.IntegralBase()).ModifyIntegral(integral);

            if (result.IndexOf("succeeded") >= 0)
            {
                string regradingObjectId = result.Split('|')[1];
            }

            return result;
        }
        #endregion

        #region 获取产品信息实体
        /// <summary>
        /// 获取产品信息实体
        /// </summary>
        /// <param name="productId"></param>
        /// <returns></returns>
        public static Model.IntegralHistoryBase GetIntegralObjById(string Id)
        {
            return (new SQLServerDAL.IntegralBase()).GetIntegralObjById(Id);
        }
        #endregion

        #region 设置产品状态
        /// <summary>
        /// 设置产品状态
        /// </summary>
        /// <param name="status"></param>
        /// <param name="productid"></param>
        /// <returns></returns>
        public static string SetProductStatus(string status, string productid)
        {
            return (new SQLServerDAL.ProductBase()).SetProductStatus(status, productid);
        }
        #endregion

        #region 验证是否重复
        /// <summary>
        /// 验证是否重复
        /// </summary>
        /// <param name="categoryid">类别Id</param>
        /// <returns></returns>
        public static bool IsExist(string name, string productId)
        {
            return (new SQLServerDAL.ProductBase()).IsExist(name, productId);
        }
        #endregion

        #region 删除产品信息
        /// <summary>
        /// 删除产品信息
        /// 是否逻辑删除(True 逻辑删除，False 物理删除)
        /// </summary>
        /// <param name="id">产品Id</param>
        /// <param name="isLogical">是否逻辑删除(True 逻辑删除，False 物理删除)</param>
        public static string Delete(string id, bool isLogical)
        {
            return (new SQLServerDAL.IntegralBase()).Delete(id, isLogical);
        }
        #endregion

        #region 修改商品价格数据
        /// <summary>
        /// 修改商品价格数据
        /// </summary>
        /// <param name="status"></param>
        /// <param name="productid"></param>
        /// <returns></returns>
        public static void UpdatePrice(decimal marketprice, decimal price, string productid, out string result)
        {
            (new SQLServerDAL.IntegralBase()).UpdatePrice(marketprice, price, productid, out result);
        }
        #endregion

        #region 修改商品库存设值
        /// <summary>
        /// 修改商品库存设值
        /// </summary>
        /// <param name="status"></param>
        /// <param name="productid"></param>
        /// <returns></returns>
        public static void UpdateStockSettings(int stockamount, int status, string productid, out string result)
        {
            (new SQLServerDAL.ProductBase()).UpdateStockSettings(stockamount, status, productid, out result);
        }
        #endregion
    }

    public class ExchangeBase
    {
        #region 产品信息添加
        /// <summary>
        /// 产品信息添加
        /// </summary>
        /// <param name="integral"></param>
        /// <returns></returns>
        public static string CreateIntegral(Model.ExchangeHistoryBase integral)
        {
            string result = (new SQLServerDAL.ExchangeBase()).CreateIntegral(integral);

            if (result.IndexOf("succeeded") >= 0)
            {
                string regradingObjectId = result.Split('|')[1];

                if (result == "succeeded")
                    result += "|" + regradingObjectId;
            }

            return result;
        }
        #endregion

        #region 产品信息修改
        /// <summary>
        /// 产品信息修改
        /// </summary>
        /// <param name="integral"></param>
        /// <returns></returns>
        public static string ModifyIntegral(Model.ExchangeHistoryBase integral)
        {
            string result = (new SQLServerDAL.ExchangeBase()).ModifyIntegral(integral);

            if (result.IndexOf("succeeded") >= 0)
            {
                string regradingObjectId = result.Split('|')[1];
            }

            return result;
        }
        #endregion

        #region 获取产品信息实体
        /// <summary>
        /// 获取产品信息实体
        /// </summary>
        /// <param name="productId"></param>
        /// <returns></returns>
        public static Model.ExchangeHistoryBase GetIntegralObjById(string Id)
        {
            return (new SQLServerDAL.ExchangeBase()).GetIntegralObjById(Id);
        }
        #endregion

        #region 设置产品状态
        /// <summary>
        /// 设置产品状态
        /// </summary>
        /// <param name="status"></param>
        /// <param name="productid"></param>
        /// <returns></returns>
        public static string SetProductStatus(string status, string productid)
        {
            return (new SQLServerDAL.ProductBase()).SetProductStatus(status, productid);
        }
        #endregion

        #region 验证是否重复
        /// <summary>
        /// 验证是否重复
        /// </summary>
        /// <param name="categoryid">类别Id</param>
        /// <returns></returns>
        public static bool IsExist(string name, string productId)
        {
            return (new SQLServerDAL.ProductBase()).IsExist(name, productId);
        }
        #endregion

        #region 删除产品信息
        /// <summary>
        /// 删除产品信息
        /// 是否逻辑删除(True 逻辑删除，False 物理删除)
        /// </summary>
        /// <param name="id">产品Id</param>
        /// <param name="isLogical">是否逻辑删除(True 逻辑删除，False 物理删除)</param>
        public static string Delete(string id, bool isLogical)
        {
            return (new SQLServerDAL.ExchangeBase()).Delete(id, isLogical);
        }
        #endregion

        #region 修改商品价格数据
        /// <summary>
        /// 修改商品价格数据
        /// </summary>
        /// <param name="status"></param>
        /// <param name="productid"></param>
        /// <returns></returns>
        public static void UpdatePrice(decimal marketprice, decimal price, string productid, out string result)
        {
            (new SQLServerDAL.IntegralBase()).UpdatePrice(marketprice, price, productid, out result);
        }
        #endregion

        #region 修改商品库存设值
        /// <summary>
        /// 修改商品库存设值
        /// </summary>
        /// <param name="status"></param>
        /// <param name="productid"></param>
        /// <returns></returns>
        public static void UpdateStockSettings(int stockamount, int status, string productid, out string result)
        {
            (new SQLServerDAL.ProductBase()).UpdateStockSettings(stockamount, status, productid, out result);
        }
        #endregion
    }
}
